import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

public class LC_94 {
    public List<Integer> inorderTraversal(LC_144.TreeNode root) {

        List<Integer> list = new ArrayList<>();
        if(root == null) return list;
        Stack<LC_144.TreeNode> stack = new Stack<>();
        LC_144.TreeNode node = root;
        while(node != null || !stack.empty()){
            if(node != null){
                stack.push(node);
                node = node.left;
            }else{
                node = stack.pop();
                list.add(node.val);
                node = node.right;
            }
        }
        return list;
    }
}
